package com.jt.controller;

import com.jt.pojo.User;
import com.jt.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@CrossOrigin
@RequestMapping("/vue")
public class SSM_VueAjaxController {
    @Autowired
    private UserService userService;

    @GetMapping("findAll")
    public List<User> findAll(){
        return userService.findAll();
    }
    @PostMapping("/insertUserOne")
    public String insertUserOne(@RequestBody User user){
        userService.saveUser(user);
        return "添加成功!";
    }
    @DeleteMapping("/deleteUserOne/{id}")
    public String deleteUserOne(@PathVariable Integer id){
        userService.deleteById(id);
        return "删除成功!";
    }
    @PutMapping("/updateUserById")
    public String updateUserById(@RequestBody User user){
        userService.updateUserById(user);
        return "数据更新成功!";
    }
}
